# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python

class Recipe(recipe.Recipe):
    name = 'mpg123'
    version = '1.25.12'
    stype = SourceType.TARBALL
    url = 'sf://.tar.bz2'
    tarball_checksum = '1ffec7c9683dfb86ea9040d6a53d6ea819ecdda215df347f79def08f1fe731d1'
    licenses = [License.LGPLv2_1Plus]
    autoreconf = True
    configure_options = '--with-audio=dummy --enable-static'
    patches = ['mpg123/0001-Disable-tools-and-libout123-library.patch']

    files_libs = ['libmpg123']
    files_devel = ['include/mpg123.h', 'include/fmt123.h', 'lib/pkgconfig/libmpg123.pc']

    def prepare(self):
        if self.config.target_platform in [Platform.ANDROID]:
            if self.config.target_arch == Architecture.ARM:
                # Disable thumb mode to get the optimizations compiled properly
                self.append_env('CFLAGS', '-marm')
                self.append_env('CCASFLAGS', '-marm')
            elif self.config.target_arch == Architecture.X86:
                # The custom assembly breaks compiling an application by
                # using relocations.
                self.configure_options += ' --with-cpu=generic '
        if self.config.target_platform in [Platform.IOS]:
            if self.config.target_arch == Architecture.X86:
                # make sure we use 32bit asm
                self.configure_options += ' --with-cpu=x86 '

